<%--
  Created by IntelliJ IDEA.
  User: zuxia
  Date: 2018/7/19
  Time: 14:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="css/amazeui.min.css">
    <link rel="stylesheet" href="css/admin.css">
</head>
<body>
<div class="admin-content-body"style="" >
    <div class="am-cf am-padding am-padding-bottom-0" >
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">管理员管理</strong><small></small></div>
    </div>
    <hr>
    <div class="am-g">
        <div class="am-u-sm-12 am-u-md-6">
            <div class="am-btn-toolbar">
                <div class="am-btn-group am-btn-group-xs">
                    <button type="button" class="am-btn am-btn-default btnAdd"><span class="am-icon-plus"></span> 新增</button>
                </div>
            </div>
        </div>
    </div>
    <div class="am-g" style="margin-top: 5px;">
        <div class="am-u-sm-12">
            <form class="am-form">
                <table class="am-table am-table-striped am-table-hover table-main">
                    <thead>
                    <tr>
                        <th class="table-id">
                            <input id="chkAll" type="checkbox">
                        </th>
                        <th>
                           编号
                        </th>
                        <th>
                            管理员名称
                        </th>
                        <th class="table-set">
                            操作
                        </th>
                    </tr>
                    </thead>
                    <tbody id="tUser">

                    </tbody>
                </table>

            </form>
        </div>
    </div>
</div>

</div>
<!-- content end -->
</div>
</div>

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="js/jquery-1.11.3.min.js"></script>
<!--<![endif]-->
<script type="text/javascript" src="myplugs/js/plugs.js"></script>
<script>
    $(function() {
        $.ajax({
            type: "get",
            url: "/isFull-admin/userSelect.action",
            datatype: "json",
            data: {},
            success: function (result) {
                    var userSelect = result.data;
                    for (var i = 0; i < userSelect.length; i++) {
                        var user = userSelect[i];
                        console.log(user);
                        $("#tUser").append(
                            " <tr><td><input name='chks' type='checkbox' value='" + user.uid + "' /></td><td>" + user.uid + "</td><td><a href='javascript:void(0)'>" + user.userNo + "</a>" +
                            "</td><td> <div class='am-btn-toolbar'> <div class='am-btn-group am-btn-group-xs'><button type='button' id='role_701' class='am-btn am-btn-default am-btn-xs am-text-secondary btnedit'>" +
                            "<span class='am-icon-pencil-square-o'></span> 编辑</button><button type='button' class='am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only  btndel'><span class='am-icon-trash-o'>" +
                            "</span> 删除<input type='hidden' name='upwd' value='" + user.upwd + "' /></button></div></div></td></tr>"
                        );
                    }
            }
        })
    });
        $("#chkAll").click(function () {
            if($(this).prop("checked")){
                $("input[name=chks]").prop("checked",true);
            }else{
                $("input[name=chks]").prop("checked",false);
            }
        });
        $(".btnedit").click(function() {

            $.jq_Panel({
                title: "修改管理员信息",
                iframeWidth: 500,
                iframeHeight: 300,
                url: "editManage.jsp"
            });
        });


        $("body").on("click",'.btndel',function() {
            var userId = $(this).parents("tr").children(":first").children("input").val();
            alert(userId);
            $.ajax({
                type:"get",
                dataType:"json",
                data:{ userId },
                url:'/isFull-admin/userDel.action',
                success:function () {
                    $(location).prop('href', '/isFull-admin/manager.jsp')
                }
            })
        });
        $(".btnAdd").click(function() {

            $.jq_Panel({
                title: "添加管理员信息",
                iframeWidth: 500,
                iframeHeight: 300,
                url: "addManager.jsp"
            });
        });
</script>
</body>

</html>